package org.springblade.pm.wrappper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.pm.entity.ManpowerPlan;
import org.springblade.pm.vo.ManpowerPlanVo;
import org.springblade.system.feign.IDictClient;

import java.util.ArrayList;
import java.util.List;

public class ManpowerPlanWrapper extends BaseEntityWrapper<ManpowerPlan,ManpowerPlanVo> {
	static IDictClient dictClient;
	static {
		dictClient = SpringUtil.getBean(IDictClient.class);
	}
	public static ManpowerPlanWrapper build() {
		return new ManpowerPlanWrapper();
	}

	@Override
	public ManpowerPlanVo entityVO(ManpowerPlan entity) {
		ManpowerPlanVo manpowerPlanVo = BeanUtil.copy(entity, ManpowerPlanVo.class);
		R<String> contractStatusName = dictClient.getValue("user_post", entity.getUserPost());
		if (contractStatusName.isSuccess()) {
			manpowerPlanVo.setUserPostName(contractStatusName.getData());
		}
		return manpowerPlanVo;
	}

	public List<ManpowerPlanVo> entityVoList(List<ManpowerPlan> list) {
		List<ManpowerPlanVo> contractVoList = new ArrayList<>();
		for (ManpowerPlan manpowerPlan : list) {
			contractVoList.add(entityVO(manpowerPlan));
		}
		return contractVoList;
	}
}
